home *** CD-ROM | disk | FTP | other *** search
/ Aminet 49 / Aminet 49 (2002)(GTI - Schatztruhe)[!][Jun 2002].iso / Aminet / util / libs / muitoolkit-src.lha / muitoolkit-2.1_src / mt_init.c < prev    next >
Encoding:
C/C++ Source or Header  |  2001-09-16  |  3.5 KB  |  115 lines

  1.  
  2. /*
  3. $Id: mt_init.c,v 1.3 1999/11/27 17:25:46 carlos Exp $.
  4. */
  5.  
  6. #include "mt_includes.h"
  7.  
  8.  
  9. ULONG __saveds __stdargs L_OpenLibs(struct MuiToolkitBase *MuiToolkitBase);
  10. void  __saveds __stdargs L_CloseLibs(void);
  11.  
  12. struct ExecBase      *SysBase       = NULL;
  13. struct IntuitionBase *IntuitionBase = NULL;
  14. struct GfxBase       *GfxBase       = NULL;
  15. struct Library       *UtilityBase   = NULL;
  16. struct DosLibrary    *DOSBase       = NULL;
  17. struct Library       *MUIMasterBase = NULL;
  18.  
  19.  
  20. char __aligned ExLibName [] = NAME;
  21. char __aligned ExLibID   [] = VERS;
  22. char __aligned Copyright [] = "© Copyright 1999 Marcin Orlowski <carlos@amiga.com.pl> All rights reserved";
  23. char __aligned VERSTRING [] = VERSTAG;
  24.  
  25.  
  26. /*************************************************************
  27. *************************************************************/
  28.  
  29. extern ULONG InitTab[];
  30. extern APTR EndResident; /* below */
  31.  
  32. struct Resident __aligned ROMTag =     /* do not change */
  33. {
  34.  RTC_MATCHWORD,
  35.  &ROMTag,
  36.  &EndResident,
  37.  RTF_AUTOINIT,
  38.  VERSION,
  39.  NT_LIBRARY,
  40.  0,
  41.  &ExLibName[0],
  42.  &ExLibID[0],
  43.  &InitTab[0]
  44. };
  45.  
  46. APTR EndResident;
  47.  
  48. struct MyDataInit                      /* do not change */
  49. {
  50.  UWORD ln_Type_Init;      UWORD ln_Type_Offset;      UWORD ln_Type_Content;
  51.  UBYTE ln_Name_Init;      UBYTE ln_Name_Offset;      ULONG ln_Name_Content;
  52.  UWORD lib_Flags_Init;    UWORD lib_Flags_Offset;    UWORD lib_Flags_Content;
  53.  UWORD lib_Version_Init;  UWORD lib_Version_Offset;  UWORD lib_Version_Content;
  54.  UWORD lib_Revision_Init; UWORD lib_Revision_Offset; UWORD lib_Revision_Content;
  55.  UBYTE lib_IdString_Init; UBYTE lib_IdString_Offset; ULONG lib_IdString_Content;
  56.  ULONG ENDMARK;
  57. } DataTab =
  58. {
  59.  INITBYTE(OFFSET(Node,         ln_Type),      NT_LIBRARY),
  60.  0x80, (UBYTE) OFFSET(Node,    ln_Name),      (ULONG) &ExLibName[0],
  61.  INITBYTE(OFFSET(Library,      lib_Flags),    LIBF_SUMUSED|LIBF_CHANGED),
  62.  INITWORD(OFFSET(Library,      lib_Version),  VERSION),
  63.  INITWORD(OFFSET(Library,      lib_Revision), REVISION),
  64.  0x80, (UBYTE) OFFSET(Library, lib_IdString), (ULONG) &ExLibID[0],
  65.  (ULONG) 0
  66. };
  67.  
  68.  
  69. /*************************************************************
  70. *************************************************************/
  71.  
  72. ULONG __saveds __stdargs L_OpenLibs(struct MuiToolkitBase *MuiToolkitBase)
  73. {
  74.  SysBase = (*((struct ExecBase **) 4));
  75.  
  76.  if( ! ( IntuitionBase = (struct IntuitionBase *) OpenLibrary("intuition.library", 37) ) )
  77.     return(FALSE);
  78.  
  79.  if( ! ( UtilityBase = OpenLibrary("utility.library", 37) ) )
  80.     return(FALSE);
  81.  
  82.  if( ! ( DOSBase = (struct DosLibrary *) OpenLibrary( "dos.library", 37) ) )
  83.      return(FALSE);
  84.  
  85.  if( ! (GfxBase = (struct GfxBase *) OpenLibrary("graphics.library", 37) ) )
  86.         return( FALSE );
  87.  
  88.  if( ! (MUIMasterBase = OpenLibrary(MUIMASTER_NAME, MUIMASTER_VMIN) ) )
  89.         return( FALSE );
  90.  
  91.  
  92.  MuiToolkitBase->mt_IntuitionBase = IntuitionBase;
  93.  MuiToolkitBase->mt_DOSBase       = DOSBase;
  94.  MuiToolkitBase->mt_GfxBase       = GfxBase;
  95.  MuiToolkitBase->mt_SysBase       = SysBase;
  96.  MuiToolkitBase->mt_UtilityBase   = (struct UtilityBase *)UtilityBase;
  97.  MuiToolkitBase->mt_MUIMasterBase = MUIMasterBase;
  98.  
  99.  
  100.  return(TRUE);
  101. }
  102.  
  103. /*************************************************************
  104. *************************************************************/
  105.  
  106. void __saveds __stdargs L_CloseLibs(void)
  107. {
  108.  if(DOSBase)       CloseLibrary((struct Library *) DOSBase );
  109.  if(GfxBase)       CloseLibrary((struct Library *) GfxBase );
  110.  if(IntuitionBase) CloseLibrary((struct Library *) IntuitionBase );
  111.  if(UtilityBase)   CloseLibrary((struct Library *) UtilityBase );
  112.  
  113.  if(MUIMasterBase) CloseLibrary((struct Library *) MUIMasterBase );
  114. }
  115.